const app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    shid: 2,
    list: [],
    intPageCount: 1,
    pageNum: 15,
    noData: false,
    FjLoginLog: wx.getStorageSync('FjLoginLog')
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    if (app.checkFjLogin()) {
      this.setData({
        FjLoginLog: wx.getStorageSync('FjLoginLog')
      })
      this.getScList();
    } else {
      wx.redirectTo({ url: '../../pages/login/index' });
    }
  },
  shTab: function (e) {
    if (e.currentTarget.dataset.shid != this.data.shid) {
      this.setData({
        shid: e.currentTarget.dataset.shid,
        intPageCount: 1,
        noData: false,
        list: []
      })
      this.getScList();
    }
  },
  toInfo: function (e) {

    if (this.data.shid == 1) {
      wx.navigateTo({
        url: '../gongqiuxinxi/detailed?gqid=' + e.currentTarget.dataset.gqid,
      })
    } else if (this.data.shid == 2) {
      wx.navigateTo({
        url: '/packageA/pages/zichanchuzhi/detailed?gqid=' + e.currentTarget.dataset.gqid,
      })
    } else {
      wx.navigateTo({
        url: '../zhaobiaogonggao/detailed?uuid=' + e.currentTarget.dataset.gqid,
      })
    }
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    this.setData({
      intPageCount: 1,
      list: []
    })
    this.getScList();
    this.onRefresh()
  },

  onRefresh: function () {
    //导航条加载动画
    wx.showNavigationBarLoading();
    setTimeout(function () {
      wx.hideNavigationBarLoading();
      //停止下拉刷新
      wx.stopPullDownRefresh();
    }, 2000);
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    if (!this.data.noData) {
      this.getScList();
    }
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },
  getScList: function () {
    if (this.data.FjLoginLog) {
      var that = this;
      var url = "api/FeijiuApp/GetMyShouCByUID?uid=" + this.data.FjLoginLog.UID + "&type=" + this.data.shid + "&intCurrPage=" + this.data.intPageCount + "&strRSA=";
      app.getDaoGet(url, function (r) {
        if (r.code == 200) {
          var list1 = that.data.list.concat(r.data.data)
          that.setData({
            list: list1
          })
          if (r.data.intPageCount > that.data.intPageCount) {
            that.setData({
              intPageCount: r.data.intPageCount
            })
          } else {
            that.setData({
              noData: true
            })
          }
        }
      })
    }
  }
})